%Retrieves signal and annotation from an ptb record
function [x,qrs_begining,t_end] = get_data_from_ptb(record)

x_struct = load(record);

x = x_struct.signals.ecg;
annotation_vect = x_struct.signals(1,1).pos(1,1);

%QRS begining
qrs_begining = zeros(1,length(x));
qrs_on_vect = annotation_vect.QRSon;

pos_qrs_x = qrs_on_vect - 1000;

for i=1:length(pos_qrs_x)
    if pos_qrs_x(i) > 0  
        if ~isnan(pos_qrs_x(i)) 
            qrs_begining(pos_qrs_x(i))=1;
        end
    end
end

%T wave end
t_end = zeros(1,length(x));

t_off_vect = annotation_vect.Toff;

pos_t_x = t_off_vect - 1000;

for i=1:length(pos_t_x)
    if ~isnan(pos_t_x(i))
        t_end(pos_t_x(i))=1;
    end
end

end